//
//  TimeManage.m
//  WWXELuShang
//
//  Created by lanou on 15/12/22.
//  Copyright © 2015年 lanou. All rights reserved.
//

#import "TimeManage.h"

@implementation TimeManage

static TimeManage *timeManage = nil;

+ (TimeManage *)sharedTimeManage {
    static dispatch_once_t once;
    dispatch_once(&once, ^{
        if (timeManage == nil) {
            timeManage = [[TimeManage alloc] init];
        }
    });
    return timeManage;
    
}

- (NSTimer *)timer {
    if (!_timer) {
        _timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(addSecond) userInfo:nil repeats:YES];
    }
    return _timer;
}

- (void)addSecond {
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSDate *senDate = [defaults valueForKey:@"sendate"];
    NSDate *alterDate = [defaults valueForKey:@"alertdate"];
    NSDate *nowDate = [NSDate date];
    self.nowTime = [nowDate timeIntervalSinceDate:senDate];
    self.alertTime = [alterDate timeIntervalSince1970] - [nowDate timeIntervalSince1970];
}




@end
